home *** CD-ROM | disk | FTP | other *** search
/ PC Graphics Unleashed / PC Graphics Unleashed.iso / xb / tif_demo.c < prev    next >
C/C++ Source or Header  |  1994-08-06  |  21KB  |  559 lines

  1. /*.............................. TIF_DEMO.C .................. 8-7-94 ......*/
  2. /* This program demonstrates the use of the TIFF reading, display and       */
  3. /* writing capabilities of the VSA256 Version 3.0 Graphics Library and      */
  4. /* the TIFF256 Graphics Library Extensions Version 3.0.                     */
  5. /*                                                                          */
  6. /* TO RUN:  - Enter VESA video mode                                         */
  7. /*          - Hit any key to continue or ESC to exit program                */
  8. /*          - Enter x,y image origin                                        */
  9. /*          - Enter full TIFF file name including path and extension        */
  10. /*          - Image is now drawn                                            */
  11. /*          - If you want to modify (invert) image and save say yes (y).    */
  12. /*          -    Then enter new name to save as.                            */
  13. /*          -    Then wait while image is modified and saved.               */
  14. /*          - Hit any key to repeat sequence or ESC to exit program         */
  15. /*                                                                          */
  16. /* NOTE: Sometimes your text input is not visible, depending on the Color   */
  17. /*       Look Up Table that is active due to last image ploted.  Keep       */
  18. /*       typing, your input will be accepted anyway.                        */
  19. /*..........................................................................*/
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include<math.h>
  23. #include<limits.h>
  24. #include <conio.h>
  25. #include <malloc.h>
  26.  
  27. #include <vsa_font.h>       /* Required to support VSA256 Graphics Library  */
  28. #include <vsa.h>            /* Required to support VSA256 Graphics Library  */
  29. #include <tiff.h>             /* Required to support TIFF256 Graphics Library */
  30.  
  31. #ifndef _MSC_VER
  32. /*.....                This is line for Borland C Only !               .....*/
  33. extern unsigned _stklen = 14000;
  34. #endif
  35.  
  36. int rainbow_lut(void);
  37. int color_bar(int, int);
  38. int prime_list(int, int);
  39. int image_stats(void);
  40. int banner(unsigned);
  41. int xform_image(int, int);
  42. void update_message(int, int, int, char *);
  43. void clear_text_area(int, int, int, int);
  44. void vsa_get_input(char *);
  45.  
  46. void main(int argc, char *argv[])
  47. {
  48.     int a,b,tx0,ty0,first,i,error,tcm=1;
  49.     unsigned vmode,xx,yy,x0,y0,ya;
  50.     unsigned long image_size;
  51.     unsigned char lut[768], huge *image;
  52.     char filename[100],key,text[100];
  53.     ya = 4;
  54.     first = 1;
  55.     if(argc> 1)
  56.         tcm = atoi(argv[1]);
  57. /*..........................................................................*/
  58. /*               Initialize video mode and VSA256 environment.              */
  59. /*               Valid modes are: 100h, 101h, 103h, and 105h.               */
  60. /*..........................................................................*/
  61.     printf("\n");
  62.     printf("Input VESA standard Video Mode (hex)\n");
  63.     printf("(100, 101, 103, or 105): ");
  64.     scanf("%x",&vmode);
  65.     if((i = vsa_init(vmode)) != 0)
  66.         {
  67.             printf("Error Initializing Requested Video Mode!\n");
  68.             if(i==1) printf("  - Did You Load Correct VESA Driver (TSR) ??\n");
  69.             if(i==2) printf("  - VESA BIOS Extensions (Driver) Not Loaded !!\n");
  70.             if(i==3) printf("  - Requested Video Mode Not Supported by this Card!\n");
  71.             if(i==4) printf("  - Mode Not an SVGA Mode Supported by this Card!\n");
  72.             if(i==5) printf("  - VESA Driver Not Returning Mode Information!\n");
  73.             return;
  74.         }
  75.     xx = XResolution;
  76.     yy = YResolution;
  77.     vsa_set_text_cursor_mode(1);
  78.     tx0 = 0.5*XResolution - 17*XCharSize;
  79.     ty0 = 0.85*YResolution;
  80. /*..........................................................................*/
  81. /*             Draw color look up table at bottom of screen.                */
  82. /*..........................................................................*/
  83.     rainbow_lut();
  84.     tf_set_prime_colors();
  85. /*..........................................................................*/
  86. /*         Turn on Adpative Palette feature for 24 bit/pixel images.        */
  87. /*         (num_colors = 256, quality = 50)                                 */
  88. /*..........................................................................*/
  89.     tf_set_true_color_mode(tcm,256,50);
  90. HERE:
  91.     a = .125*xx;
  92.     b = .91*yy;
  93.     color_bar(a,b);
  94. /*..........................................................................*/
  95. /*                   Draw Prime Colors at screen right.                     */
  96. /*..........................................................................*/
  97.     a = xx - 11*XCharSize;
  98.     b = ya*YCharSize+4;
  99.     prime_list(a,b);
  100. /*..........................................................................*/
  101. /*                          Draw a banner                                   */
  102. /*..........................................................................*/
  103.     banner(ya);
  104. /*..........................................................................*/
  105. /*                         Outline Screen                                   */
  106. /*..........................................................................*/
  107.     vsa_set_color(TF_Red);
  108.     vsa_move_to(0,0);
  109.     vsa_rect(xx-1,yy-1);
  110.     vsa_move_to(1,1);
  111.     vsa_rect(xx-2,yy-2);
  112. /*..........................................................................*/
  113. /*  This next block of code demonstrates some simple Color Look Up Table    */
  114. /*  modications and also saving a new TIFF file. (Skipped on first pass.)   */
  115. /*..........................................................................*/
  116.     if((first == 0) && (!error))
  117.         {
  118.             clear_text_area(tx0,ty0-YCharSize,51,TF_Black);
  119.             update_message(tx0,ty0,TF_Green,
  120.                                              "Want to Transform and Save as new TIFF ? (y,n): ");
  121.             key = getch();
  122.             if((key == 'y') || (key == 'Y'))
  123.                 {
  124.                     update_message(tx0,ty0,TF_Green,"Enter Path and Filename to save as: ");
  125.                     vsa_get_input(filename);
  126.                     update_message(tx0,ty0,TF_Green,"TRANSFORMING and SAVING !!");
  127.                     xform_image(x0,y0);
  128.                     error = tf_save_file(x0,y0,x0+(unsigned)TF_ImageWidth-1,
  129.                                                              y0+(unsigned)TF_ImageLength-1,filename);
  130.                     if(error == -1)
  131.                         {
  132.                             update_message(tx0,ty0-YCharSize,TF_Red,"Error Trying To Save TIFF File!");
  133.                             update_message(tx0,ty0,TF_Yellow,"Press Any Key to exit.");
  134.                             getch();
  135.                             goto BAIL;
  136.                         }
  137.                 }
  138.         }
  139.     first = 0;
  140. /*..........................................................................*/
  141. /*         Wait for any key to continue; if ESC key, quit program.          */
  142. /*..........................................................................*/
  143.     update_message(tx0,ty0,TF_Yellow,"Press ESC to exit, Any other key to continue ...");
  144.     key = getch();
  145.     if(key == 27)
  146.         goto BAIL;
  147. /*..........................................................................*/
  148. /*                   Get picture start coordinates.                         */
  149. /*..........................................................................*/
  150.     clear_text_area(tx0,ty0-YCharSize,51,TF_Black);
  151.     update_message(tx0,ty0,TF_Red,"Input picture origin (x0,y0): ");
  152.     vsa_get_input(text);
  153.     sscanf(text,"%d,%d",&x0,&y0);
  154.     x0 += 5;
  155.     y0 += ya*YCharSize+4;
  156. /*..........................................................................*/
  157. /*                            Open TIFF File.                               */
  158. /*..........................................................................*/
  159. FILENAME:
  160.     update_message(tx0,ty0,TF_Green,"Input full Filename: ");
  161.     vsa_get_input(filename);
  162.     error = tf_open_file(filename);
  163.     if(error == -1)
  164.         {
  165.             update_message(tx0,ty0-YCharSize,TF_Red,"Can't Find Specified File! ... Try Again.   ");
  166.             goto HERE;
  167.         }
  168. /*..........................................................................*/
  169. /*                      Get TIFF File information.                          */
  170. /*..........................................................................*/
  171.     error = tf_get_file_info();
  172.     if(error == 1)
  173.         update_message(tx0,ty0-YCharSize,TF_Red,"File Read Error!                            ");
  174.     if(error == 2)
  175.         update_message(tx0,ty0-YCharSize,TF_Red,"File Shorter Than Expected!                 ");
  176.     if(error == 3)
  177.         update_message(tx0,ty0-YCharSize,TF_Red,"Bad TIFF File!                              ");
  178.     if(error)
  179.         goto NOTSUPPORTED;
  180. /*..........................................................................*/
  181. /*  Prior to reading the image information, set defaults for all globals.   */
  182. /*..........................................................................*/
  183.     tf_set_defaults();
  184. /*..........................................................................*/
  185. /* Read image information.  Globals are set, pointers to image data are     */
  186. /* extracted. Also Provide friendly error messages!                         */
  187. /*..........................................................................*/
  188.     error = tf_read_ifd();
  189.     if(error == 1)
  190.         update_message(tx0,ty0-YCharSize,TF_Red,"NULL TIFF file Pointer!                      ");
  191.     if(error == 2)
  192.         update_message(tx0,ty0-YCharSize,TF_Red,"Error Seeking in File!                       ");
  193.     if(error == 3)
  194.         update_message(tx0,ty0-YCharSize,TF_Red,"File Read error!                             ");
  195.     if(error == 4)
  196.         update_message(tx0,ty0-YCharSize,TF_Red,"Greater than 8 Bit Palette Pixels Not Supported!");
  197.     if(error == 5)
  198.         update_message(tx0,ty0-YCharSize,TF_Red,"Samples Per Pixel > 3 Not Supported!         ");
  199.     if(error == 6)
  200.         update_message(tx0,ty0-YCharSize,TF_Red,"Only 8x8x8 Bit True Color Pixels Supported!  ");
  201.     if(error == 7)
  202.         update_message(tx0,ty0-YCharSize,TF_Red,"Compressed TIFF data Not Supported!          ");
  203.     if(error == 8)
  204.         update_message(tx0,ty0-YCharSize,TF_Red,"This Photometric Interpretation Not Supported!");
  205.     if(error == 9)
  206.         update_message(tx0,ty0-YCharSize,TF_Red,"Currently Only Support up to 1024 Strips!    ");
  207.     if(error == 10)
  208.         update_message(tx0,ty0-YCharSize,TF_Red,"Samples Per Pixel > 3 Not Supported!         ");
  209.     if(error == 11)
  210.         update_message(tx0,ty0-YCharSize,TF_Red,"Currently Only Support up to 1024 Strips!    ");
  211.     if(error == 12)
  212.         update_message(tx0,ty0-YCharSize,TF_Red,"This Planar Configuration Not Supported!     ");
  213.     if(error == 13)
  214.         update_message(tx0,ty0-YCharSize,TF_Red,"This Predictor Not Supported!                ");
  215.     if(error == 14)
  216.         update_message(tx0,ty0-YCharSize,TF_Red,"Color Map Size > 256 Not Supported!          ");
  217.     if(error)
  218.         goto NOTSUPPORTED;
  219.     if(TF_SamplesPerPixel == 3)
  220.         {
  221.             if(tcm > 1)
  222.                 update_message(tx0,ty0-YCharSize,TF_Red,
  223.                 "Please Wait - Calculating ADAPTIVE Palette.     ");
  224.             if(tcm == 1)
  225.                 update_message(tx0,ty0-YCharSize,TF_Red,
  226.                 "Please Wait - Dithering RGB Image.");
  227.         }
  228. /*..........................................................................*/
  229. /*                 Display TIFF image starting at (x0,y0).                  */
  230. /* Note, Two methods are shown below.  One is commented out, your choice.   */
  231. /*..........................................................................*/
  232.     if(tf_display_ifd(x0,y0) != 0)
  233.         {
  234.             update_message(tx0,ty0-YCharSize,TF_Red,"Low Memory: Turning Adaptive Palette OFF!       ");
  235.             tf_set_true_color_mode(1,255,50);
  236.             tf_display_ifd(x0,y0);
  237.             tf_set_true_color_mode(2,255,50);
  238.         }
  239.  
  240. /*......... The following shows alternate method using tf_load_image ......
  241.     image_size = tf_image_size();
  242.     image = (unsigned char huge *)halloc(image_size,1);
  243.     if(image == NULL)
  244.         {
  245.             error = 1;
  246.             update_message(tx0,ty0-YCharSize,TF_Red,"Error - Not enough memory for image!");
  247.             getch();
  248.             goto NOTSUPPORTED;
  249.         }
  250.     if(tf_load_image(image,lut) < 2)
  251.         {
  252.             update_message(tx0,ty0-YCharSize,TF_Red,"Low Memory: Turning Adaptive Palette OFF!       ");
  253.             tf_set_true_color_mode(1,255,50);
  254.             tf_load_image(image,lut);
  255.             tf_set_true_color_mode(2,255,50);
  256.         }
  257.     vsa_write_color_block(0,256,lut);
  258.     vsa_put_image(x0,y0,image,0);
  259.     hfree(image);
  260.     ......................  End of alternate method ........................*/
  261.  
  262. /*..........................................................................*/
  263. /*                 Restore Prime Color Values.                              */
  264. /*..........................................................................*/
  265.     tf_set_prime_colors();
  266. /*..........................................................................*/
  267. /*                            Frame new image.                              */
  268. /*..........................................................................*/
  269.     vsa_set_color(TF_White);
  270.     vsa_move_to(x0-2,y0-2);
  271.     vsa_rect(x0+(unsigned)TF_ImageWidth+1,y0+(unsigned)TF_ImageLength+1);
  272.     vsa_set_color(TF_Black);
  273.     vsa_move_to(x0-1,y0-1);
  274.     vsa_rect(x0+(unsigned)TF_ImageWidth,y0+(unsigned)TF_ImageLength);
  275. /*..........................................................................*/
  276. /*                 Update Image Statistics                                  */
  277. /*..........................................................................*/
  278.     image_stats();
  279. /*..........................................................................*/
  280. /*                        Close opened TIFF file.                           */
  281. /*..........................................................................*/
  282. NOTSUPPORTED:
  283.     tf_close_file();
  284.     goto HERE;
  285. /*..........................................................................*/
  286. /*                       Restore text video mode and Bail Out.              */
  287. /*..........................................................................*/
  288. BAIL:
  289.     tf_about();
  290.     getch();
  291.     vsa_init(0x03);
  292.     return;                       /*.....            End main            .....*/
  293. }
  294.  
  295.  
  296. rainbow_lut()
  297. {
  298.     int i,start,count;
  299.     unsigned char color_array[768];
  300.     for(i=0;i<224;i++)
  301.         {
  302.             color_array[3*i+2]=0;
  303.             color_array[3*i+1]=0;
  304.             color_array[3*i]=0;
  305.         }
  306. /*................................ RED .....................................*/
  307.     for(i=0;i<56;i++)
  308.         {
  309.                 color_array[3*i] = 63*sin((i*6.28)/112.0);
  310.         }
  311. /*............................... BLUE .....................................*/
  312.     for(i=0;i<126;i++)
  313.         {
  314.                 color_array[3*i+2] = 63*sin((i*6.28)/252.0);
  315.         }
  316. /*............................... GREEN ....................................*/
  317.     for(i=96;i<210;i++)
  318.         {
  319.                 color_array[3*i+1] = 63*sin(((i-90)*6.28)/252.0);
  320.         }
  321. /*................................ RED .....................................*/
  322.     for(i=140;i<224;i++)
  323.         {
  324.                 color_array[3*i]   = 63*sin(((i-140)*6.28)/280.0);
  325.         }
  326.     start = 32;
  327.     count = 224;
  328.     vsa_write_color_block(start,count,color_array);
  329.     return 0;
  330. }
  331.  
  332.  
  333. color_bar(x0,y0)
  334. int x0,y0;
  335. {
  336.     int i;
  337.     unsigned xx,yy,a,b;
  338.     float c;
  339.     xx = XResolution;
  340.     yy = YResolution;
  341. /*..........................................................................*/
  342. /*     Draw outline for color bar.                                          */
  343. /*..........................................................................*/
  344.     vsa_set_color(TF_White);
  345.     vsa_move_to(x0-1,y0-1);
  346.     a = .75*xx;
  347.     b = .065*yy;
  348.     vsa_rect(x0+a+1,y0+b+1);
  349.     c = (float)a/256;
  350.     for(i=0;i<256;i++)
  351.         {
  352.             vsa_set_color((unsigned char)i);
  353.             vsa_move_to(x0+(unsigned)(i*c),y0);
  354.             vsa_rect_fill(x0+(unsigned)(c+i*c),y0+b);
  355.         }
  356.     return 0;
  357. }
  358.  
  359. prime_list(x0,y0)
  360. int x0,y0;
  361. {
  362.     int tx0,ty0;
  363.     unsigned xxx;
  364.  
  365.     xxx = x0 + 9*XCharSize;
  366.  
  367.     tx0 = x0;
  368.     ty0 = y0;
  369.     vsa_set_color(TF_Black);
  370.     update_message(tx0,ty0,TF_White,"Black =  ");
  371.     vsa_move_to(xxx,ty0);
  372.     vsa_rect_fill(xxx+XCharSize,ty0+YCharSize-4);
  373.  
  374.     ty0 += YCharSize;
  375.     vsa_set_color(TF_Red);
  376.     update_message(tx0,ty0,TF_Red,"Red =    ");
  377.     vsa_move_to(xxx,ty0);
  378.     vsa_rect_fill(xxx+XCharSize,ty0+YCharSize-4);
  379.  
  380.     ty0 += YCharSize;
  381.     vsa_set_color(TF_Orange);
  382.     update_message(tx0,ty0,TF_Orange,"Orange = ");
  383.     vsa_move_to(xxx,ty0);
  384.     vsa_rect_fill(xxx+XCharSize,ty0+YCharSize-4);
  385.  
  386.     ty0 += YCharSize;
  387.     vsa_set_color(TF_Yellow);
  388.     update_message(tx0,ty0,TF_Yellow,"Yellow = ");
  389.     vsa_move_to(xxx,ty0);
  390.     vsa_rect_fill(xxx+XCharSize,ty0+YCharSize-4);
  391.  
  392.     ty0 += YCharSize;
  393.     vsa_set_color(TF_Green);
  394.     update_message(tx0,ty0,TF_Green,"Green =  ");
  395.     vsa_move_to(xxx,ty0);
  396.     vsa_rect_fill(xxx+XCharSize,ty0+YCharSize-4);
  397.  
  398.     ty0 += YCharSize;
  399.     vsa_set_color(TF_Aqua);
  400.     update_message(tx0,ty0,TF_Aqua,"Aqua =   ");
  401.     vsa_move_to(xxx,ty0);
  402.     vsa_rect_fill(xxx+XCharSize,ty0+YCharSize-4);
  403.  
  404.     ty0 += YCharSize;
  405.     vsa_set_color(TF_Blue);
  406.     update_message(tx0,ty0,TF_Blue,"Blue =   ");
  407.     vsa_move_to(xxx,ty0);
  408.     vsa_rect_fill(xxx+XCharSize,ty0+YCharSize-4);
  409.  
  410.     ty0 += YCharSize;
  411.     vsa_set_color(TF_Violet);
  412.     update_message(tx0,ty0,TF_Violet,"Violet = ");
  413.     vsa_move_to(xxx,ty0);
  414.     vsa_rect_fill(xxx+XCharSize,ty0+YCharSize-4);
  415.  
  416.     ty0 += YCharSize;
  417.     vsa_set_color(TF_White);
  418.     update_message(tx0,ty0,TF_White,"White =  ");
  419.     vsa_move_to(xxx,ty0);
  420.     vsa_rect_fill(xxx+XCharSize,ty0+YCharSize-4);
  421.  
  422.     return 0;
  423. }
  424.  
  425. image_stats()
  426. {
  427.     char text[100];
  428.     int tx0,ty0;
  429.  
  430.     tx0 = 39*XCharSize;
  431.     ty0 = YCharSize;
  432.  
  433.     sprintf(text,"Width  = %d     ",TF_ImageWidth);
  434.     update_message(tx0,ty0,TF_White,text);
  435.     ty0 += YCharSize;;
  436.     sprintf(text,"Length = %d     ",TF_ImageLength);
  437.     update_message(tx0,ty0,TF_White,text);
  438.     ty0 = YCharSize;
  439.     tx0 = 55*XCharSize;
  440.     if(TF_PhotometricInterpretation < 2)
  441.         {
  442.             update_message(tx0,ty0,TF_White,"Color Model = Bilevel or");
  443.             ty0 += YCharSize;;
  444.             update_message(tx0,ty0,TF_White,"              GrayScale ");
  445.             ty0 += YCharSize;;
  446.             sprintf(text,"%d Bits Per Pixel        ",TF_BitsPerSample[0]);
  447.             update_message(tx0,ty0,TF_White,text);
  448.             ty0 += YCharSize;;
  449.         }
  450.     if(TF_PhotometricInterpretation == 2)
  451.         {
  452.             update_message(tx0,ty0,TF_White,"Color Model = True Color");
  453.             ty0 += YCharSize;;
  454.             update_message(tx0,ty0,TF_White,"24 Bits Per Pixel       ");
  455.             ty0 += YCharSize;;
  456.             update_message(tx0,ty0,TF_White,"(8 bits each R,G,B)     ");
  457.             ty0 += YCharSize;;
  458.         }
  459.     if(TF_PhotometricInterpretation == 3)
  460.         {
  461.             update_message(tx0,ty0,TF_White,"Color Model = Palette   ");
  462.             ty0 += YCharSize;;
  463.             sprintf(text,"%d Bits Per Pixel        ",TF_BitsPerSample[0]);
  464.             update_message(tx0,ty0,TF_White,text);
  465.             ty0 += YCharSize;;
  466.             update_message(tx0,ty0,TF_White,"                        ");
  467.             ty0 += YCharSize;;
  468.         }
  469.     if(TF_PhotometricInterpretation > 3)
  470.         update_message(tx0,ty0,TF_White,"Color Model = Unknown   ");
  471.     return 0;
  472. }
  473.  
  474. banner(ya)
  475. unsigned ya;
  476. {
  477.     int tx0,ty0;
  478.     unsigned xx;
  479.     xx = XResolution;
  480.     vsa_move_to(0,0);
  481.     vsa_set_color(TF_Red);
  482.     vsa_rect(xx-1,ya*YCharSize);
  483.     vsa_move_to(38*XCharSize,0);
  484.     vsa_line_to(38*XCharSize,ya*YCharSize);
  485.     vsa_move_to(38*XCharSize+1,0);
  486.     vsa_line_to(38*XCharSize+1,ya*YCharSize);
  487.     ty0 = YCharSize;
  488.     tx0 = 2*XCharSize;
  489.     vsa_write_string(tx0,ty0,TF_Green,"TIFF256 GRAPHICS LIBRARY EXTENSIONS");
  490.     vsa_write_string(tx0,ty0+YCharSize,TF_Green,"           VERSION 3.0  ");
  491.     vsa_write_string(tx0,ty0+2*YCharSize,TF_Green,"  Copyright Spyro Gumas 1992 - 1994");
  492.     return 0;
  493. }
  494.  
  495. xform_image(x0,y0)    /* Cheap Negative maker */
  496. int x0,y0;
  497. {
  498.     unsigned char array[1024];
  499.     int i,j;
  500.     for(j=y0;j<y0+TF_ImageLength;j++)
  501.         {
  502.             vsa_get_raster_line(x0,(unsigned)(x0+TF_ImageWidth-1),j,array);
  503.             for(i=0;i<TF_ImageWidth;i++)
  504.                 array[i] = 255 - array[i];
  505.             vsa_raster_line(x0,(unsigned)(x0+TF_ImageWidth-1),j,array);
  506.         }
  507.     return 0;
  508. }
  509.  
  510.  
  511. void update_message(int x0,int y0,int color,char *text)
  512. {
  513.     clear_text_area(x0,y0,51,TF_Black);
  514.     vsa_write_string(x0,y0,color,text);
  515.     vsa_set_color(color);
  516.     return;
  517. }
  518.  
  519. void clear_text_area(int x0,int y0,int length,int color)
  520. {
  521.     vsa_set_color(color);
  522.     vsa_move_to(x0,y0);
  523.     vsa_rect_fill(x0+length*XCharSize-1,y0+YCharSize-1);
  524.     return;
  525. }
  526.  
  527. /*.......................... VSA_GET_INPUT .................... 6-25-94 ....*/
  528. /*  This routine reads the keyboard input and echos it to the screen until  */
  529. /* a carriage return is entered. Then the whole text string is returned     */
  530. /* via 'text'.                                                              */
  531. /*..........................................................................*/
  532. void vsa_get_input(char *text)
  533. {
  534.     int i,x,y;
  535.     char key;
  536.     vsa_get_text_cursor(&x,&y);
  537.     i=0;
  538.     text[0] = 0;
  539.     while((key = getch()) != 13)               /*  Do until a return is hit.  */
  540.         {
  541.             if(key != 8)
  542.                 {                                    /*  If not a back space        */
  543.                     text[i] = key;                     /*  add key entry to string.   */
  544.                     text[i+1] = 0;
  545.                     vsa_write_string(x,y,TF_White,text);/*  Echo the updated string.   */
  546.                     i++;
  547.                 }
  548.             else
  549.                 {                                    /*  If a back space            */
  550.                     if(i > 0) i --;                    /*  delete last key entry.     */
  551.                     text[i] = 92;
  552.                     vsa_write_string(x,y,TF_White,text);/*  Echo the updated string.   */
  553.                     text[i] = 0;
  554.                 }
  555.         }
  556.     return;
  557. }
  558.  
  559.